package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.ContractDao;
import cn.topevery.garden.entity.po.Contract;
import cn.topevery.garden.entity.query.ContractQuery;
import cn.topevery.garden.framework.base.BaseLogic;
import com.github.dozermapper.core.Mapper;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 
 *
 * @author code-generate
 * @date 2021-08-06
 */
@Service
public class ContractLogic extends BaseLogic<Contract> {
    @Autowired
    ContractDao contractDao;
    @Autowired
    private Mapper mapper;

    @Override
    public BaseEntityDao<Contract, Integer> getDao() {
        return contractDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<Contract> listPage(ContractQuery query) {
        return contractDao.listPage(query);
    }

    public  boolean saveOrUpdate(String userId, Contract entity){
        contractDao.saveOrUpdate(userId, entity);
        return true;
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId, Integer[] ids) {
        contractDao.delete(userId, ids);
    }

    /**
     * 描述 检查是否已经存在.
     *
     * @param fieldName 字段名
     * @param value     字段值
     * @return the boolean （true已存在，false不存在）
     * @author wenzhao.lin
     * @created 2021 -08-19 09:23:47 Is exit boolean.
     */
    public  boolean isExit(String fieldName, String value){
        return contractDao.isExit(fieldName, value);
    }
}
